//
//  TRFindPagerFragmentAdapter.m
//  WeiMiLan
//
//  Created by anan on 14/11/22.
//  Copyright (c) 2014年 Mac. All rights reserved.
//

#import "TRFindPagerFragmentAdapter.h"

@implementation TRFindPagerFragmentAdapter

- (id)initWithViewController:(UIViewController*)viewController
{
    self = [super initWithViewController:viewController];
    if (self) {
        self.fragments = [[NSMutableArray alloc]init];
        self.titles = [[NSMutableArray alloc]init];
        self.viewController = viewController;
        [self addNewsItem];
        [self addMyFollowItem];
        [self addAskBuyItem];
    }
    return self;
}

/**
 *  获取tab的个数
 *
 *  @return
 */
- (int)getCount
{
    return (int)self.fragments.count;
}

/**
 *  获取指定tab的Fragment
 *
 *  @param viewPager
 *  @param position
 *
 *  @return
 */
- (QLFragment*)getFragment:(QLViewPager *)viewPager position:(int)position
{
    return [self.fragments objectAtIndex:position];
}

- (NSString*)getTitle:(QLViewPager *)viewPager position:(int)position
{
    return [self.titles objectAtIndex:position];
}

- (void)addNewsItem
{
    TRFindFragment *fragment = [[TRFindFragment alloc] initWithXibName:@"TRFindNewsListView" viewController:self.viewController];
    fragment.viewController = self.viewController;
    [self.fragments addObject:fragment];
    [self.titles addObject:@"新内参"];
}

- (void)addAskBuyItem
{
    TRFindFragment *fragment = [[TRFindFragment alloc] initWithXibName:@"TRAskBuyListView" viewController:self.viewController];
    fragment.viewController = self.viewController;
    [self.fragments addObject:fragment];
    [self.titles addObject:@"找合作"];
}

- (void)addMyFollowItem
{
    TRFindFragment *fragment = [[TRFindFragment alloc] initWithXibName:@"TRFindFollowListView" viewController:self.viewController];
    fragment.viewController = self.viewController;
    [self.fragments addObject:fragment];
    [self.titles addObject:@"我关注"];

}

@end
